package com.huajiao.management_system.controller;

import com.huajiao.management_system.bean.superadmin;
import com.huajiao.management_system.service.superadminService;
import com.huajiao.management_system.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;


@Controller
@Api(tags = "管理员相关接口")
public class superadminController {
    @Resource
    private superadminService superadminservice;

    @PostMapping(value = "/login")
    @ApiOperation(value = "登录", notes="用户名和密码登录")
    @ResponseBody
    public Result login(String username, String password) {
        System.out.println(username+password);
        if (StringUtils.isEmpty(username) || StringUtils.isEmpty(password)){
            return new Result("用户名或密码不能为空！");
        }
       superadmin supadmin = superadminservice.login(username,password);
        if (supadmin != null){
            return new Result("欢迎您！伟大的超级管理员大人！");
        }else {
            return new Result("用户名或密码错误！");
        }
    }
}
